//
//  UIImage+Extension.swift
//  YYWeibo
//
//  Created by strongwallyi on 16/1/8.
//  Copyright © 2016年 strongwallyi. All rights reserved.
//

import UIKit

extension UIImage {
    
    //截屏
    //截屏
    class func getScreenShot() -> UIImage {
        let window = UIApplication.sharedApplication().keyWindow
        
        //开启图形上下文
        UIGraphicsBeginImageContextWithOptions(window!.frame.size, false, 0)
        //将 window 中得内容画到图形上下文中
        window?.drawViewHierarchyInRect(CGRect(origin: CGPointZero, size: window!.frame.size), afterScreenUpdates: false)
        //获取图片
        let image = UIGraphicsGetImageFromCurrentImageContext()
        //关闭图形上下文
        UIGraphicsEndImageContext()
        //返回
        return image
    }
    
    
    
}
